Repository navigation
feat(id): seitan admission path for id serve (#8487) - #8529
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 1 minute. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 524f2c288f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…8487) Codex P2 on PR #8529: registration unconditionally inserted a fresh Invite (used: None) under the same deterministic invite ID, so a retried or duplicated registration after redemption reset the single-use state and the same token could admit another account. Registration now preserves an existing registry entry (entry().or_insert): idempotent for retries, and a genuinely new invite uses a new token. Regression test: seitan_duplicate_registration_does_not_reset_single_use_state (register, admit, re-register, same proof refuses used).
…merge PR #8529 added the SeitanState parameter to web_routers; the mixed-listener test from PR #6809 still called it with 12 arguments, so the --features web lib-test build did not compile on main. Pass SeitanState::default(), as the other in-file call sites do. Drive-by: this blocks every web-feature test, including the new #5728 bridge tests.
Implements #8487 (task 14862, lane code-p), per the design recorded on the issue by task 14857 (comment 6786323656). On merge: check off the #798 brief line-76 item and close #5119 with this evidence (its last open item) — handled by the task's completion pass, not this PR body alone.
What lands
Serve web surface (
pkgs/id/src/web/seitan.rs, new) —SeitanState: the invite registry (HashMap<invite-id-hex, RegisteredInvite { world, invite }>), the server'sDirectory, and the resolved freshness window behind one mutex; clones share the one registry.POST /api/seitan/invite— registration, gated by the same admin-secret check asPOST /api/world/invite(hub lease for the named world +admin_okon thex-world-admin-tokenheader; no hub → 404, busy → 503, bad/absent secret → 401). Body{token, world, expires_ms}; the server buildsInvite::create(token, now, expires_ms)and stores it; the response carries only the invite ID. The token is never stored (Invitekeeps ID + public key + expiry by construction) and never logged.POST /api/seitan/admit— unauthenticated; the signed proof is the credential. Body{message, signature}, both hex. Handler order per the design: unparseable proof → 400malformed; no registry entry → 404unknown_invite(nothing consumed);uidnaming no directory account → 403unknown_account, checked from the parsed fields beforeadmit, so the invite is not consumed;Invite::admitrefusal → 403 with theRejectreason (revoked/expired/used/stale/from_future/bad_key/bad_signature); success appendsAccountVerifiedviaDirectory::verify_account(Actor::Server, …)before the 200{uid, eldest_seqno, world}— if the append fails after a successful admit, a loud 500 and the invite stays consumed (single-use safety over retry convenience).Window (
pkgs/id/src/commands/serve.rs) —serve_freshness_window(started)mirrorsserve_pull_policy:started.config.freshness().window()when a server config is loaded,seitan::DEFAULT_WINDOW(5 min) when none is. Incmd_serve, theSeitanStateis built with that window and aDirectoryopened on the server-config directory journal beside the groups log (after provisioning persisted into it, so provisioned accounts are visible to the admit account check) and threaded throughweb::web_routers→finish_router→AppState.seitan(the same pattern asgroups_log). Other router constructors keep the default state.Tests
web/routes.rstest idiom (tower oneshot overcreate_router), plus the admin-gate test:(a) happy path under a non-default configured window — a proof signed 8 min before invite creation (outside the 5-min default, inside the configured 10-min) admits and
AccountVerifiedlands in the directory;(b) a proof signed 5 min before creation under a 1-min configured window refuses
stalethrough the live path;(c) no-config default state admits a fresh proof under the default window;
(d) unknown invite → 404
unknown_invite;(e) unknown account → 403
unknown_account, then the same proof succeeds after the account is keyed in (invite not consumed);(f) invite registration without/with a wrong admin secret → 401.
serve_freshness_windowunit tests mirroring theserve_pull_policypair (no-config default; configured 60 s window read from[policy] freshness_window_seconds).Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.